<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * motto: 现在的努力是为了小时候吹过的牛逼！
 * Date: 2020/3/6
 * Time: 20:17
 */
namespace app\common\lib;

class ClassArr {

    public static function smsClassStat(){
        return [
            "ali"=>"app\common\lib\sms\AliSms",
            "baidu"=>"app\common\lib\sms\BaiduSms",
            "jd"=>"app\common\lib\sms\JdSms",
        ];

    }

    public static function uploadClassStat(){
        return  [
            'text'=>'baidu',
            'image'=>'jd'
        ];
    }

    public static function initClass($type, $class, $param = [], $needInstance = false ){
        //如果我们工厂模式调用的方法是静态的，那么我们这个地方返回类库
        // 如果不是静态的呢，我们就需要返回 对象
        if (!array_key_exists($type,$class)){
                return false;
        }
        $className = $class[$type];

        //new ReflectionClass('AliSms') => 建立AliSms反射类
        //->newInstanceArgs($args) => 相当于实例化A对象
        return $needInstance == true ?(new \ReflectionClass($className))->newInstanceArgs($param):$className;
    }
}
